<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>生命周期</title>
    <script src="script/vue-2.4.0.js"></script>
</head>

<body>
    <div id="app">
        <h1>{{number}}</h1>
        <button @click="add">修改number</button>
    </div>
    <script>
        Vue.config.productionTip = false //关闭生成信息提示
        var vm = new Vue({
            el: '#app',
            data: {
                number: 100,
            },
            methods: {
                add() {
                    this.number++
                }
            },
            beforeCreate() {
                console.log('组件创建之前钩子函数')
            },
            created() {
                console.log('组件创建完毕钩子函数')
            },
            beforeMount() {
                console.log('组件挂载之前钩子函数')
            },
            mounted() {
                console.log('组件挂载完毕钩子函数')
            },
            beforeUpdate() {
                console.log('组件更新之前钩子函数')
            },
            updated() {
                console.log('组件更新完毕钩子函数')
            },
            beforeDestroy() {
                console.log('组件销毁之前钩子函数')
            },
            destroyed() {
                console.log('组件销毁完毕钩子函数')
            },
            filters: {},
            directives: {}
        })
        vm.$destroy() //调用组件销毁
    </script>
</body>

</html>